package com.uchiha.nova.core.model.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.uchiha.nova.core.tool.node.INode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 中国区域机构代码 模型VO
 *
 * @author Chill
 */
@Data
public class ChinaOrgCodeVO implements INode<ChinaOrgCodeVO>, Serializable {

	private static final long serialVersionUID = 1L;
	/**
	 * 编码
	 */
    @Schema(description = "编码")
	private Long id;
	/**
	 * 名称
	 */
    @Schema(description = "名称")
	private String name;
	/**
	 * 级别
	 */
    @Schema(description = "级别")
	private Integer level;
	/**
	 * 父编码
	 */
    @Schema(description = "父编码")
	private Long parentId;

	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<ChinaOrgCodeVO> children;

	@Override
	public List<ChinaOrgCodeVO> getChildren() {
		if (this.children == null) {
			this.children = new ArrayList<>();
		}
		return this.children;
	}

	/**
	 * 是否有子孙节点
	 */
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private Boolean hasChildren;

	@Override
	public Boolean getHasChildren() {
		if (this.children == null||this.children.size()==0) {
			return false;
		}
		return true;
	}
}
